303
And would get as a result:
Two Sample t-test
data: GroupA and GroupB
t = 1.0377, df = 14, p-value = 0.317
alternative hypothesis: true difference in means is not equal to
095 percent confidence interval:
-1.066768 3.066768
sample estimates:
mean of x mean of y
10 9
A p-value of 0.317 was found, which means that we cannot reject the null hypothesis.
Thus, the new therapy does not show any significant improvement with regard to the aver
age duration of illness.
We can now use a chi-square test (test for independence) to determine whether the two
variables are independent, that is, whether the number of airbags is independent of the
type of car.
Analogous to the two previous examples, we must also formulate the test hypothesis
here (p-value < 0.05). The null hypothesis (H0) would be: Both variables are independent.
The alternative hypothesis H1: The number of airbags depends on the type of car.
In R we would use the following script (clipboard loads data from cache, just copy the
table to do this):
> table<-read.table(clipboard)
> chisq.test(table)
And would get as a result:
Pearson's Chi-squared test
data: table
Example 19.3
19.3
Table 19.3 Number of airbags in different car types
Compact
Large
Medium
Small
Sports
Van
Driver/passenger
2
4
7
0
3
0
Driver
9
7
11
5
8
3
None
5
0
4
16
3
6
19.6 Introduction to Programming (Meta Tutorial)